
<template>
  <div>
    <Modal
      v-model="tongBu"
      title="商标数据同步"
      :footer-hide="true"
      :mask-closable="false"
      @on-visible-change="vChange"
      width="800"
      class-name="vertical-center-modal"
    >
      <Table
        :data="tableData"
        :columns="columns"
        stripe
        border
        :max-height="$app.winHeight-250"
        class="marginB10"
      ></Table>
    </Modal>
  </div>
</template>




<script>
export default {
  name: "tm_synchro",
  components: {},
  data() {
    let data = {
      tableData: [],
      columns:[
        {
          title: " ",
          type: "index",
          width: 30,
          align: "center ",
          className: "goOnTxt c999"
        },
        {
          title: "申请人",
          className: "goOnTxt",
          key: "people_name",
          resizable: true,
        },
        {
          title: "最新数量",
          className: "goOnTxt",
          width:150,
          resizable: true,
          render: (h, params) => {
            let {
              row: {
                official_count
              }
            } = params;
            let out = [];


            out.push(
              h('span', {
                class: "  cRed f_bold ",
              }, official_count)
            );



            return out;
          }
        },
        {
          title: "已管理数量",
          className: "goOnTxt",
          key: "manage_count",
          width:150,
          resizable: true,
        },
        {
          title: "操作",
          width:80,
          className: "goOnTxt",
          align:'center',
          render: (h, params) => {
            let {
              row: {
                people_name
              }
            } = params;
            let out = [];


            out.push(
              h('Button', {
                  props: {
                      type: 'primary',
                      size: 'small',
                  },
                  on: {
                      click: () => {
                        $ajax.lb_getImportByRegPeople(people_name, res => {
                          this.getData();

                          // 如果只有一条数据，关闭弹框
                          if(this.tableData.length==1){
                            this.tongBu=false;
                          }

                          $app.toast("导入成功，请10分钟后查看结果", true);
                        });
                      }
                  }
              }, '同 步')
            );



            return out;
          }
        }
      ],


      tongBu:false
    };
    return data;
  },
  // props:['userPower','companyAll'],
  watch:{
    // userPower(newVal,oldVal){

    //   this.mobile=newVal.mobile;

    // },
    // companyAll(newVal,oldVal){
    //   this.companyAll=newVal;
    // },
  },
  created() {
    
  },
  methods: {
    getData(){
      $ajax.tmManage_tmUpdateList(resData=>{
        this.$emit('genX_Fun',resData.total);
        this.tableData = resData.people_list;
      });
    },
    //提交
    goFun() {
      
    },
    //弹框消失
    vChange(buEr) {
      if(!buEr){
        this.$emit('getTmList');
      }
    }
  }
};
</script>
